package com.atguigu.c_designed.m1createModel.c4builder.ext;

public class BuilderPhone {
    private String cpu;
    private String screen;
    private String memory;
    private String mainboard;

    private BuilderPhone(Builder builder) {
        this.cpu = builder.cpu;
        this.screen = builder.screen;
        this.memory = builder.memory;
        this.mainboard = builder.mainboard;
    }

    @Override
    public String toString() {
        return "BuilderPhone{" +
                "cpu='" + cpu + '\'' +
                ", screen='" + screen + '\'' +
                ", memory='" + memory + '\'' +
                ", mainboard='" + mainboard + '\'' +
                '}';
    }

    public static final class Builder {
        private String cpu;
        private String screen;
        private String memory;
        private String mainboard;

        Builder cpu(String cpu) {
            this.cpu = cpu;
            return this;
        }

        Builder screen(String screen) {
            this.screen = screen;
            return this;
        }

        Builder memory(String memory) {
            this.memory = memory;
            return this;
        }

        Builder mainboard(String mainboard) {
            this.mainboard = mainboard;
            return this;
        }

        BuilderPhone build() {
            return new BuilderPhone(this);
        }
    }
}

class ClientPhone {
    public static void main(String[] args) {
        BuilderPhone builder = new BuilderPhone.Builder()
                .cpu("AMD")
                .mainboard("ASUS")
                .memory("KingStore")
                .screen("SUMSANG").build();
        System.out.println(builder);
    }
}